//
//  NSDictionary+HACShield.m
//  HACShield
//
//  Created by Chengjie on 2019/5/22.
//

#import "NSDictionary+HACShield.h"
#import "NSObject+HACSwizzling.h"

@implementation NSDictionary (HACShield)

/**
 __NSDictionary0 = @{};
 __NSSingleEntryDictionaryI = @{@"key":@"xxx"};
 __NSDictionaryI = @{@"key":@"xxx", @"key1":@"xxx信息",};
 */
+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        // *** 👇 以下内容可以不需要，因为方法不存在已经被 HACCrashSavior 拯救了
        NSArray *tempArr = @[hac_getClass(@"__NSD", @"ictionary0"), hac_getClass(@"__NSS", @"ingleEntryDictionaryI"), hac_getClass(@"__NSD", @"ictionaryI")];
        for (Class cls in tempArr) {
            SEL sel_set_obj = @selector(setObject:forKey:);
            hac_swizzleInstanceMethod(cls, sel_set_obj, @selector(hac_setObject:forKey:));
            SEL sel_remove_obj = @selector(removeObjectForKey:);
            hac_swizzleInstanceMethod(cls, sel_remove_obj, @selector(hac_removeObjectForKey:));
            SEL sel_add_entries = @selector(addEntriesFromDictionary:);
            hac_swizzleInstanceMethod(cls, sel_add_entries, @selector(hac_addEntriesFromDictionary:));
        }
    });
}

- (void)hac_setObject:(id)anObject forKey:(id<NSCopying>)aKey {}

- (void)hac_removeObjectForKey:(id)aKey {}

- (void)hac_addEntriesFromDictionary:(NSDictionary *)otherDictionary {}

@end
